package com.newx.common.core.enums.business;

import com.newx.common.core.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 投资组合订单状态枚举
 */
@Getter
@AllArgsConstructor
public enum GroupOrderStatusEnum {
    /**
     * 进行中
     */
    NOW(0, "进行中"),
    /**
     * 已完成
     */
    END(1, "已完成"),
    ;

    /**
     * 状态码
     */
    private final Integer code;

    /**
     * 状态描述
     */
    private final String info;
    //根据code返回枚举
    public static GroupOrderStatusEnum getEnumByCode(Integer code) {
        for (GroupOrderStatusEnum lendOrderStatusEnum : values()) {
            if (Objects.equals(code, lendOrderStatusEnum.getCode())) {
                return lendOrderStatusEnum;
            }
        }
        throw new ServiceException("订单状态不存在");
    }
}
